package com.wswy.wyjk.ui.drawable

import android.graphics.*
import android.graphics.drawable.Drawable

abstract class BaseDrawable : Drawable() {

    protected val paint = Paint(Paint.ANTI_ALIAS_FLAG)

    protected val rect = Rect()

    protected val rectF = RectF()


    override fun onBoundsChange(bounds: Rect?) {
        super.onBoundsChange(bounds)
        rect.set(bounds)
        rectF.set(rect)
    }

    override fun setAlpha(alpha: Int) {
        paint.alpha = alpha
    }

    override fun getOpacity(): Int {
        return PixelFormat.TRANSLUCENT
    }

    override fun setColorFilter(colorFilter: ColorFilter?) {
        paint.colorFilter = colorFilter
    }


    override fun getIntrinsicHeight(): Int {
        return rect.height()
    }

    override fun getIntrinsicWidth(): Int {
        return rect.width()
    }
}